﻿<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"
    Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Account_Master.aspx.cs"
    EnableSessionState="True" Inherits="iGRID_Ooredoo_SPCRM_My_Opportunities.Layouts.iGRID_Ooredoo_SPCRM_My_Opportunities.Account_Master"
    DynamicMasterPageFile="~masterurl/default.master" %>

<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
    <style type="text/css">
        .trig_formvalidations
        {
            color: Red;
        }
    </style>
</asp:Content>
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
    <table cellpadding="5" cellspacing="5" width="50%">
        <tr>
            <td style="padding-left: 5px">
                Find
                <asp:TextBox runat="server" ID="txtAccName" Width="500px"></asp:TextBox>
            </td>
            <td>
                <asp:ImageButton runat="server" ID="btnGetAcc" OnClick="btnGetAcc_Click" ImageUrl="~/_layouts/iGRID_Ooredoo_SPCRM_Opportunity_Forms/Images/search.png" />
            </td>
        </tr>
        <tr>
            <td colspan="2">
            <div runat="server" id="divGv" style="height:210px; border:0.5px 0.5px 0.5px 0.5px; border-color:#ddd; border-style:solid" >
                <asp:GridView runat="server" ID="gvAcc" AutoGenerateColumns="false" EnableModelValidation="True"
                    CssClass="tbl-default" AllowPaging="true" OnPageIndexChanging="gvAcc_PageIndexChanging"
                    PageSize="5" Width="100%" OnSelectedIndexChanged="gvAcc_OnSelectedIndexChanged"
                    OnRowDataBound="gvAcc_RowDataBound"  >
                                     
                    <Columns>
                        <asp:BoundField DataField="Title" HeaderText="Customer Name" />
                        <asp:BoundField DataField="Customer_x0020_ID" HeaderText="Customer ID" />
                        <asp:BoundField DataField="Phone" HeaderText="Phone" />
                        <asp:BoundField DataField="Email_x0020_ID" HeaderText="E-Mail ID" />
                        <%--<asp:CommandField HeaderText="Select" InsertVisible="False" ButtonType="Image" SelectImageUrl="~/_layouts/iGRID_Ooredoo_SPCRM_Opportunity_Forms/Images/Select.jpg"
                            ShowSelectButton="true" />--%>
                    </Columns>
                    <SelectedRowStyle BackColor="#D1DDF1" ForeColor="#333333" />
                    <PagerSettings FirstPageText="First Page" LastPageText="Last Page" Mode="NumericFirstLast" 
                        Position="Bottom" />
                </asp:GridView>
                </div>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <asp:Label runat="server" ID="lblError" CssClass="error-alt" Visible="false"></asp:Label>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Image ID="img" runat="server" ImageUrl="~/_layouts/iGRID_Ooredoo_SPCRM_Opportunity_Forms/Images/Add.png" />
                <asp:LinkButton runat="server" ID="btnNewItems" OnClick="btnNewItems_Click" Text="Add Account" />
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <table id="tblAddItems" cellpadding="0" cellspacing="0" class="tbl-default" runat="server"
                    width="100%">
                    <tr>
                        <td>
                            Customer Name <span title="This is a required field." class="trig_formvalidations"><strong>
                                *</strong></span>
                        </td>
                        <td>
                            <asp:TextBox runat="server" ID="txtCustomer" Width="99%"></asp:TextBox>
                            <%-- <asp:RequiredFieldValidator runat="server" ID="r1" ControlToValidate="txtCustomer"
                                Display="Static" ErrorMessage="Please enter customer name"></asp:RequiredFieldValidator>--%>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Customer ID <span title="This is a required field." class="trig_formvalidations"><strong>
                                *</strong></span>
                        </td>
                        <td>
                            <asp:TextBox runat="server" ID="txtCustomerID" Width="99%"></asp:TextBox>
                            <%--<asp:RequiredFieldValidator runat="server" ID="r2" ControlToValidate="txtCustomerID"
                                Display="Static" ErrorMessage="Please enter customer id"></asp:RequiredFieldValidator>--%>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Phone
                        </td>
                        <td>
                            <asp:TextBox runat="server" ID="txtPhone" Width="99%" onkeypress="return isNumberKey(this)"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            E-Mail ID
                        </td>
                        <td>
                            <asp:TextBox runat="server" ID="txtMailID" Width="99%"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Web Site
                        </td>
                        <td>
                            <asp:TextBox runat="server" ID="txtWebsite" Width="99%"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" align="right">
                            <asp:Button runat="server" ID="btnRecSave" Text="Save" OnClick="btnRecSave_Click"
                                OnClientClick="javascript:return ItemValidation();" CssClass="ms-ButtonHeightWidth">
                            </asp:Button>
                            <asp:Button runat="server" ID="btnRecCancel" Text="Close" OnClick="btnRecCancel_Click"
                                CssClass="ms-ButtonHeightWidth"></asp:Button>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td colspan="2" style="padding-top: 10px">
                <asp:TextBox runat="server" ID="hdnSessionAccName" Width="99%" Height="20px" ReadOnly="true"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td align="right" colspan="2" style="padding-right: 10px">
                <%--<asp:Button runat="server" ID="btnProceed" Text="OK" Enabled="false" OnClientClick="parent.document.location.href=parent.document.location.href"
                    CssClass="ms-ButtonHeightWidth" />--%>
                <asp:Button runat="server" ID="btnProceed" Text="OK" Enabled="false" OnClientClick="javascript:return updateParent();"
                    CssClass="ms-ButtonHeightWidth" />
                <asp:Button runat="server" ID="btnClose" Text="Close" OnClick="btnClose_Click" CssClass="ms-ButtonHeightWidth"
                    OnClientClick="javascript:window.close();" />
            </td>
        </tr>
        <%--<asp:UpdateProgress ID="UpdateProgress2" runat="server" AssociatedUpdatePanelID="UptSummary"
            DisplayAfter="0">
            <ProgressTemplate>
                <center>
                    <img src="/_layouts/1033/IMAGES/loading.gif" alt="Loading..." height="200px" /></center>
            </ProgressTemplate>
        </asp:UpdateProgress>--%>
    </table>
    <script language="javascript" type="text/javascript">

        function updateParent() {

            debugger;
            var oVal = document.getElementById('<%= hdnSessionAccName.ClientID %>').value;
            window.opener.setValue(oVal);
            window.close();
            return false;
        } 
  
    </script>
    <script language="javascript" type="text/javascript">
        function isNumberKey(evt) {
            var charCode = (evt.which) ? evt.which : event.keyCode
            if (charCode > 31 && (charCode < 48 || charCode > 57))
                return false;
            return true;
        }


        function ItemValidation() {


            var customer = document.getElementById("<%=txtCustomer.ClientID %>"); // gets value from hours dropdown list for 1st datetime control
            var customerID = document.getElementById("<%=txtCustomerID.ClientID %>");

            if (customer.value == "") {
                alert('Customer Name cannot be blank');
                customer.focus();
                return false;
            }

            else {

                if (customerID.value == "") {
                    alert('Customer ID cannot be blank');
                    customerID.focus();
                    return false;
                }

                else {
                    if (document.getElementById('<%= txtMailID.ClientID  %>').value != "") {
                        var email;
                        email = document.getElementById('<%= txtMailID.ClientID %>');
                        var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
                        if (!filter.test(email.value)) {
                            alert('Please provide a valid email address');
                            email.focus();
                            return false;
                        }
                    }
                }
            }

        }

    </script>
</asp:Content>
<asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">
    Select Account
</asp:Content>
<asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea"
    runat="server">
    Account Master
</asp:Content>
